"""
@Project ：Python_Learning 
@File    ：4.私有属性.py
@IDE     ：PyCharm 
@Author  ：zhupp
@Date    ：2024/10/3 17:38 
"""
class Date:
    def __init__(self, year, month, day):
        """
        构造方法:
        :param year:
        :param month:
        :param day:
        """
        self.year = year
        self.month = month
        self.day = day

    # 实例方法
    def __str__(self):
        return f"{self.year}.{self.month}.{self.day}"

    # 静态方法
    @staticmethod
    def parse_from_str(date_str):  # 传参不传参都可以
        year, month, day = date_str.split('-')   # 对data_str解包（split()分割后会传入一个列表之中）
        return Date(int(year), int(month), int(day))

    # 类方法
    @classmethod
    def parse_string(cls, date_str):  # cls指的是类本身
        year, month, day = date_str.split('-')
        return cls(int(year), int(month), int(day))

class User:
    def __init__(self, birthday):
        self.__birthday = birthday

    def get_age(self):
        return 2024 - self.__birthday.year


if __name__ == '__main__':
    user1 = User(Date(2000, 10, 3))
    print(user1.get_age())
    print(user1._User__birthday)